define(function(require, exports, module) {

  var Backbone = require('backbone');
  var $ = require('jquery');
  var _ = require('underscore');
  var jsonview = require('jsonview');

  var Grid = require('./topoGrid');

  var Icon = require('../renderer/icon')
  var Line = require('../renderer/line')

  require('css!../css/style.css')

  function main() {
    var $app = $('<div id="app">').height(window.env.h);
    $('#main').html($app);
    app($app);
  }

  function app($app) {

    var grid = new Grid($app[0]);

    var sourceNode = grid.createNode({width: 100, height: 100, x:20, y:20});
    var icon = new Icon(sourceNode);
    grid.bindNode(sourceNode, icon)

    var targetNode = grid.createNode({width: 100, height: 100, x:200, y:200})
    var icon2 = new Icon(targetNode);
    grid.bindNode(targetNode, icon2)

    var edgeNode = grid.createEdge({
      source: {node: sourceNode, direction: 'e'},
      target: {node: targetNode, direction: 'w'}
    });
    var line = new Line(edgeNode);
    grid.bindEdge(edgeNode, line)


    grid.render()
  }

  return main;
})
